package com.liuyang.demo.time;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
import java.util.Date;

public class LocalDateTest {
    public static void main(String[] args) {

        Date cDate = new Date();
        LocalDate startDate = cDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
        Date changeTime =new Date();

        LocalDate startLocalDate = changeTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(1);
        /*LocalDateTime startLocalTime = startLocalDate.atStartOfDay();
        LocalDateTime endLocalTime1 = startLocalDate.plusDays(7).atStartOfDay();
        LocalDateTime endLocalTime2 = startLocalDate.plusDays(7).atStartOfDay().minusSeconds(1);

        System.out.println("changeTime:"+changeTime);//Thu Apr 08 17:20:11 CST 2021
        System.out.println("startLocalDate:"+startLocalDate);//2021-04-09
        System.out.println("startLocalTime:"+startLocalTime);//2021-04-09T00:00
        System.out.println("endLocalTime1:+"+endLocalTime1);//2021-04-16T00:00
        System.out.println("endLocalTime2:+"+endLocalTime2);//2021-04-15T23:59:59*/
        Date from = Date.from(LocalDateTime.of(startDate.plusDays(1 + 1), LocalTime.MIN)
                .atZone(ZoneId.systemDefault()).toInstant());
        System.out.println(from);
        long endTime = Date.from(LocalDateTime.of(startDate.plusDays(1 + 1), LocalTime.MIN)
                .atZone(ZoneId.systemDefault()).toInstant()).getTime();
        System.out.println(endTime);
    }
}
